import { SceneDTO, SceneSaveForm } from '@/api/entity/scene'
import request from '@utils/request'
import { APIParams, APIResult } from '@utils/request/type'
import { ServerEnum } from '@/api/enum/server'
import { DeviceDTO } from '@/api/entity/device'

/**
 * 分页查询
 * @param params
 */
export const getSceneListByPageAPI = (params: APIParams.Page<{
  // 模糊查询
  q?: string,
  // 开始时间
  startTime?: string,
  // 结束时间
  endTime?: string
}>) => request.post<APIResult.Page<SceneDTO[]>>(ServerEnum.System + '/group/page', params)

/**
 * 获取场景列表
 */
export const getSceneListAPI = () => request.post<APIResult<SceneDTO[]>>(ServerEnum.System + '/group/list')

/**
 * 添加场景
 * @param params
 */
export const addSceneAPI = (params: SceneSaveForm) => request.post(ServerEnum.System + '/group/add', params)

/**
 * 编辑场景
 * @param params
 */
export const editSceneAPI = (params: SceneSaveForm) => request.post(ServerEnum.System + '/group/edit', params)

/**
 * 删除场景
 * @param params
 */
export const delSceneAPI = (params: { id: string }) => request.get(ServerEnum.System + '/group/delete/' + params.id)

/**
 * 场景下设备排序
 * @param params
 */
export const sceneSortAPI = (params: {
  id: string,
  // 关联设备
  deviceDTOList: DeviceDTO[]
}) => request.post(ServerEnum.System + '/group/sort', params)
